/*

Frequency of use: 1 2 3 4 [5] HIGH 

Short:
    Façade hides a lot of complex behaviour behind a simple, single interface.  
It puts a shop-front on an otherwise complex set of classes.
    
Long:    
    The facade pattern is a software engineering design pattern commonly used 
with Object-oriented programming. (The name is by analogy to an architectural 
facade.)
A facade is an object that provides a simplified interface to a larger body of 
code, such as a class library. A facade can:

 - make a software library easier to use and understand, since the facade has 
convenient methods for common tasks;

 - make code that uses the library more readable, for the same reason;
reduce dependencies of outside code on the inner workings of a library, since 
most code uses the facade, thus allowing more flexibility in developing the 
system;

 - wrap a poorly-designed collection of APIs with a single well-designed API (as 
per task needs).

An Adapter is used when the wrapper must respect a particular interface and must 
support a polymorphic behavior. On the other hand, a facade is used when one 
wants an easier or simpler interface to work with.

Information sources:
 - http://calumgrant.net/patterns/index.html
 - http://en.wikipedia.org/wiki/Facade_pattern
 - http://www.dofactory.com/Patterns/Patterns.aspx
*/

#include <string>
#include <iostream>

class HelloWorld
{
public:
	virtual ~HelloWorld() { }
	virtual std::string hello()=0;
	virtual std::string world()=0;
	virtual void output(const std::string&)=0;
	virtual void endl()=0;
};

class HelloWorldImpl : public HelloWorld
{
public:
	std::string hello() { return "Hello"; }
	std::string world() { return "world"; }
	void output(const std::string & str)
	{
		std::cout << str;
	}
	void endl()
	{
		std::cout << std::endl;
	}
};

void hello_world(HelloWorld & hw)
{
	hw.output(hw.hello());
	hw.output(" ");
	hw.output(hw.world());
	hw.output("!");
	hw.endl();
}

int main()
{
	HelloWorldImpl hw;
	hello_world(hw);
	return 0;
}

